package com.yunsc.shop.controller.shop;


import com.yunsc.common.utils.Result;
import com.yunsc.shop.utils.ClientInfoUtils;
import com.yunsc.system.dto.ShopLoginDTO;
import com.yunsc.store.service.YunscLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2024-04-11 14:36
 */
@Api(value = "登入接口", tags = "ShopLoginController")
@Slf4j
@RestController()
public class ShopLoginController {

    @Resource
    private YunscLoginService loginService;
    @Resource
    private ClientInfoUtils clientInfoUtils;

    @ApiOperation(value = "登录", notes = "登录参数: username, password", httpMethod = "POST")
    @PostMapping(value = "/passport/login")
    public Result<?> storeLogin(@RequestBody ShopLoginDTO param) {
        String platform = clientInfoUtils.getCurrentPlatform();
        Integer storeId = clientInfoUtils.getCurrentStoreId();
        log.info("当前平台:{},当前门店:{}", platform, storeId);
        Map<String, Object> map = loginService.shopLogin(param, platform, storeId);
        return Result.ok("登录成功", map);
    }


}
